/* Yet Another Experimental Software Renderer
 *
 * Copyright (c) 2010 Pawel "Hery" Dziepak
 */

#include "output_merger.h"

using namespace yaesr;

void default_om::draw(int x, int y, color clr, double z) {
	Assert(depth != NULL);
	Assert(next != NULL);

	// depth test
	double old = depth->get_pixel(x, y).a;
	if (old < z)
		return;

	depth->put_pixel(x, y, color(z));
	next->put_pixel(x, y, clr);
}

void default_om::set_next(pixel_output *po) {
	output_merger::set_next(po);

	if (!depth)
		depth = depth_texture::create(po->get_width(), po->get_height());
}
